package com.hollycrm.ahunicom.sheet.business.hibernate;

import java.util.List;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Query;
import net.sf.hibernate.Session;

import org.springframework.orm.hibernate.HibernateCallback;
import org.springframework.orm.hibernate.HibernateTemplate;
import org.springframework.orm.hibernate.support.HibernateDaoSupport;

import com.hollycrm.ahunicom.sheet.business.OperationRecord;
import com.hollycrm.ahunicom.sheet.business.OperationRecordDao;
import com.hollycrm.unicom.code.GeneralCode;
import com.hollycrm.unicom.sheet.generalCode.hibernate.GeneralCodeRms;

public class HibernateOperationRecord extends HibernateDaoSupport 
	implements OperationRecordDao{

	public List getResultRecord(final String parameter) {
		HibernateTemplate template = getHibernateTemplate();
		return  (List) template.execute(new HibernateCallback() {

			public Object doInHibernate(Session session)
					throws HibernateException {
				Query queryObj = session.createQuery("from OperationRecord cr " +
						"where cr.sheetFlowNo = '" + parameter +"' order by cr.id");
				return queryObj.list();
			}
		});
	}

	public void save(OperationRecord operationRecord) {
		HibernateTemplate ht = getHibernateTemplate();
		ht.save(operationRecord);
	}

	public void update(GeneralCode gc) {
		HibernateTemplate ht = getHibernateTemplate();
		ht.update(gc);
	}
}
